package com.oto.model;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

/**
 * @author xueqiang.mi
 * @since 2010-12-18
 */
@PersistenceCapable(table = "Account", identityType = IdentityType.APPLICATION)
public class AccountDO implements Serializable {
	private static final long serialVersionUID = 2417567812870751573L;
	@PrimaryKey
	private String name;
	@Persistent
	private String nickName;
	@Persistent
	private String type;
	@Persistent
	private Date crtDate;
	@Persistent
	private Date modDate;
	@Persistent
	private Set<String> friends;
	@Persistent
	private Set<Long> toQueue; // 用于点对点消息推送
	@Persistent
	private Set<Long> subQueue; // 用于主动订阅
	@Persistent
	private Set<Long> publicQueue; // 用于公共消息推送

	public Date getCrtDate() {
		return crtDate;
	}

	public Set<String> getFriends() {
		if (friends == null) {
			friends = new HashSet<String>();
		}
		return friends;
	}

	public Date getModDate() {
		return modDate;
	}

	public String getName() {
		return name;
	}

	public String getNickName() {
		return nickName;
	}

	public Set<Long> getPublicQueue() {
		return publicQueue;
	}

	public Set<Long> getSubQueue() {
		if (subQueue == null) {
			subQueue = new HashSet<Long>();
		}
		return subQueue;
	}

	public Set<Long> getToQueue() {
		if (toQueue == null) {
			toQueue = new HashSet<Long>();
		}
		return toQueue;
	}

	public String getType() {
		return type;
	}

	public void setCrtDate(Date crtDate) {
		this.crtDate = crtDate;
	}

	public void setFriends(Set<String> friends) {
		this.friends = friends;
	}

	public void setModDate(Date modDate) {
		this.modDate = modDate;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}

	public void setPublicQueue(Set<Long> publicQueue) {
		if (publicQueue == null) {
			publicQueue = new HashSet<Long>();
		}
		this.publicQueue = publicQueue;
	}

	public void setSubQueue(Set<Long> subQueue) {
		this.subQueue = subQueue;
	}

	public void setToQueue(Set<Long> toQueue) {
		this.toQueue = toQueue;
	}

	public void setType(String type) {
		this.type = type;
	}

	@Override
	public String toString() {
		return "AccountDO [name=" + name + ", nickName=" + nickName + ", friends=" + friends + ", crtDate=" + crtDate
				+ ", modDate=" + modDate + ", publicQueue=" + publicQueue + ", subQueue=" + subQueue + ", toQueue=" + toQueue
				+ ", type=" + type + "]";
	}

}
